// import { local } from '@/utils/storage'
// import { getAreaData } from '@/api/modules/common'
export default {
  data() {
    return {
      areaData: [],
      props: {
        multiple: false, // 是否多选
        label: 'name',
        value: 'id',
        children: 'children'
      }
    }
  },
  created() {
    // this.getAreaData()
  },
  methods: {
    /* async getAreaData() {
      const areaData = local.readData('area-data')
      if (Object.keys(areaData).length !== 0) {
        this.areaData = areaData
      } else {
        const { data } = await getAreaData()
        const formatData = this.formatData(data)
        local.saveData('area-data', formatData)
        this.areaData = formatData
      }
    },*/
    // 格式化地址树
    formatData(data) {
      data.forEach(item => {
        if (item.children && item.children.length !== 0) {
          this.formatData(item.children)
        } else {
          item.children = null
        }
      })
      return data
    }
  }
}
